package com.dongjiantong.common.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author cao
 * @create 2017-12-19 上午11:42
 **/
public class JsonUtil {
    /**
     * 把对象转换成json字符串
     * @param obj
     * @return
     */
    public static String toJsonString(Object obj)
    {
        ObjectMapper mapper = new ObjectMapper();

        String jsonStr="";
        try {
            jsonStr = mapper.writeValueAsString(obj);

        }
        catch (JsonProcessingException ex)
        {}
        return jsonStr;
    }
}
